@section('scripts')
<script type="text/javascript">
$(document).ready(function(){
	$('#typeSelect').change(function(){
		$('#selectForm').submit(); 
	});
});
</script>
@stop

@section('content')
<div class="row">
	<div class="col-md-6">
		<h2>SEO</h2>
	</div>
</div>

<div class="row">
	<div class="col-md-4">
		<p>
		{{ Form::open(array('url' => 'admin/seo', 'method' => 'get', 'id' => 'selectForm', 'role' => 'form')) }}
			{{ Form::select(
				'type', 
				['products' => 'Products', 'categories'	=> 'Categories'], 
				$type, 
				['id' => 'typeSelect' ,'class' => 'form-control']
			) }}
		{{ Form::close() }}
		</p>
	</div>
</div>

<div class="row">
	<div class="col-md-12">
     	<table class="table table-hover table-bordered table-striped">
		<thead>
			<tr>
				<th>Name</th>
				<th>SEO Title</th>
				<th>SEO Description</th>
				<th>SEO Keywords</th>
				<th>Action</th>
			</tr>
		</thead>
		<tbody>
			@foreach ($lists as $item)
			<tr>
				<td>{{ $item->name }}</td>
				@if ($seo = $item->seo->first())
					<td>{{ $seo->title }}</td>
					<td>{{ $seo->description }}</td>
					<td>{{ $seo->keywords }}</td>
					<td><a href="{{ url('admin/seo/' . $seo->id . '/edit?type=' . $type . '&id=' . $item->id) }}">Edit</a></td>
				@else
					<td></td>
					<td></td>
					<td></td>
					<td><a href="{{ url('admin/seo/create?type=' . $type . '&id=' . $item->id) }}">Add</a></td>
				@endif 
			</tr>
			@endforeach
		</tbody>
		</table>
	</div>
</div>
@stop